﻿
using BoriPeter.FatSecret.Models;
using BoriPeter.FitnessJournal8.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BoriPeter.FatSecret.Converters
{
    public static class ExerciseEntriesGetConverter
    {
        public static DailyEntry Convert(this ExerciseEntriesGetModel _inModel)
        {
            DailyEntry dailyEntry = new DailyEntry();
            dailyEntry.ExerciseEntries = new ObservableCollection<ExerciseEntry>();

            if (_inModel.Entries != null)
            {
                foreach (var item in _inModel.Entries)
                {
                    ExerciseEntry newEntry = new ExerciseEntry();
                    newEntry.ExreciseId = item.ExreciseId;
                    newEntry.ExerciseName = item.ExerciseName;
                    newEntry.Minutes = item.Minutes;
                    newEntry.Calories = item.Calories;

                    dailyEntry.ExerciseEntries.Add(newEntry);
                }
            }

            return dailyEntry;
        }
    }
}
